package com.vito.framework.system.message.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.vito.framework.base.controller.BaseController;
import com.vito.support.ApiResponse;

/***************************************************************
 * Name:        WelcomeAction.java     
 * Create At:   2010-04-22
 * Module:      系统管理
 * Description: [系统管理-欢迎首页]
 * Author       zhaowentao
 * ------------------------------------------------------------
 * 修改历史
 * 序号         日期                 修改人                          修改原因
 * 1   2012.6.18    xuyunchao   添加公告信息提示框
 * 2
***************************************************************/
@RestController
@RequestMapping("${adminPath}/message")
public class MessageController extends BaseController {

	@PostMapping(value = "/count", consumes = "application/json;charset=UTF-8")
	public int count(HttpServletRequest request, @RequestBody JSONObject params) {
		try {
			return 3;
		} catch (Exception e) {
			return 0;
		}
	}

	@PostMapping(value = "/init", consumes = "application/json;charset=UTF-8")
	public ApiResponse init(HttpServletRequest request, @RequestBody JSONObject params) {
		try {
			return ApiResponse.ok(0);
		} catch (Exception e) {
			return ApiResponse.of(e);
		}
	}

	@PostMapping(value = "/content", consumes = "application/json;charset=UTF-8")
	public ApiResponse content(HttpServletRequest request, @RequestBody JSONObject params) {
		try {
			return ApiResponse.ok("消息内容");
		} catch (Exception e) {
			return ApiResponse.of(e);
		}
	}

	@PostMapping(value = "/has_read", consumes = "application/json;charset=UTF-8")
	public boolean has_read(HttpServletRequest request, @RequestBody JSONObject params) {
		try {
			return true;
		} catch (Exception e) {
			return false;
		}
	}
	
	@PostMapping(value = "/remove_readed", consumes = "application/json;charset=UTF-8")
	public boolean remove_readed(HttpServletRequest request, @RequestBody JSONObject params) {
		try {
			return true;
		} catch (Exception e) {
			return false;
		}
	}
}
